package kr.saeildamil.androidstudy.ch08;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Toast;

public class HandleOrder extends Activity {
	//교재 368페이지 내용
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View view = new MyView(this);
		// 리스너 우선순위1
		view.setOnTouchListener(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					Toast.makeText(
							HandleOrder.this,
							"Listener : Touch Event Received", Toast.LENGTH_SHORT).show();
					//return true;
				}
				return false;
			}
		});
		setContentView(view);
	}
	
	public class MyView extends View{
		public MyView(Context context){
			super(context);
		}
	//뷰의 콜백 메소드 우선순위2
		public boolean onTouch(View v, MotionEvent event) {
			if (event.getAction() == MotionEvent.ACTION_DOWN) {
				Toast.makeText(
						HandleOrder.this,
						"View : Touch Event Received", Toast.LENGTH_SHORT).show();
				//return true;
			}
			return false;
		}
	
	}
	//액티비티의 콜백 메소드 우선순위3
	public boolean onTouch(View v, MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			Toast.makeText(
					HandleOrder.this,
					"Activity : Touch Event Received", Toast.LENGTH_SHORT).show();
			return true;
		}
		return false;
	}
}
	
	
	
	
	